#pragma once
#include "PhysEngine.h"
#include "Ogre.h"
#include <memory>
#include <vector>

class GameObject
{
public: 
	GameObject(Ogre::SceneNode* node, btRigidBody* body, bool temp):
		node(node),
		body(body),
		temp(temp)
	{}
	void syncPhysicsAndGraphics();
	Ogre::SceneNode* node;
	btRigidBody* body;
	bool temp;
};

class World
{
public:
	World(Ogre::SceneManager* sceneManager);
	GameObject* addObject(Ogre::SceneNode* node, btCollisionShape* shape, const btTransform& transform, float mass, bool temp = false);
	void removeObject(GameObject* object);
	void addJoint(btTypedConstraint* joint, bool disableCollision);
	void update(bool syncPhysicsAndGraphics);
	void setPause(bool pause) {this->pause = pause;}
	bool getPause() const{return pause;}
	void reset(bool syncPhysicsAndGraphics);
	size_t getStep() const;
	Ogre::SceneManager* getSceneManager();
	~World();
private:
	size_t step;
	bool pause;
	std::vector<GameObject*> objects;
	std::auto_ptr<PhysEngine> physEngine;
	Ogre::SceneManager* sceneManager;
};
